<div bsModal #createPromotionModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="createPromotionModal" aria-hidden="true" [config]="{backdrop: 'static'}">
    <div class="modal-dialog modal-lg" *ngIf="promotion">
        <div class="modal-content form">
            <form *ngIf="active" #createPromotionForm="ngForm" class="horizontal-form" novalidate (ngSubmit)="save()">
                <div class="modal-header">
                    <button type="button" class="close" (click)="close()" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title">
                        <span>添加推广信息</span>
                    </h4>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-md-9">
                            <div class="form-group">
                                <label class="control-label">名称</label>
                                <input class="form-control input-sm" type="text" id="name" name="name" [(ngModel)]="promotion.name" required maxlength="32" minlength="2">
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">地区:</label>
                        <div class="">
                            <select name="province" class="input-sm form-control areadrop" id="province" (ngModelChange)="provinceChange($event)" [ngModel]="promotion.provinceId">
                          <option [value]="province.id" *ngFor='let province of provinces.items'>{{province.name}}</option>
                        </select>
                            <select name="city" class="input-sm form-control areadrop" id="city" (ngModelChange)="cityChange($event)" [ngModel]="promotion.cityId">
                          <option [value]="city.id" *ngFor='let city of cities.items'>{{city.name}}</option>
                        </select>
                            <select name="district" class="input-sm form-control areadrop" id="district" [(ngModel)]="promotion.districtId">
                          <option [value]="district.id" *ngFor='let district of districts.items'>{{district.name}}</option>
                        </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">标题轮播</label>
                        <webuploader [options]="imgOptions" (onReady)="onImgReady($event)" (onDestroy)="onImgDestroy()">
                            <div id="uploader-demo" class="wu-example">
                                <div id="fileList" class="uploader-list">
                                    <ng-template [ngIf]="promotion.attachmentIds.length>0">
                                        <div *ngFor="let fileId of promotion.attachmentIds" [id]="'images'+fileId" class="file-item thumbnail upload-state-done">
                                            <img [src]="editorConfig.imageUrlPrefix+fileId" style="width:100px;height:100px;" alt="" />
                                            <div class="info"></div>
                                        </div>
                                    </ng-template>
                                </div>
                                <div id="filePicker">选择文件</div>
                            </div>
                        </webuploader>
                    </div>
                    <div class="row">
                        <div class="col-md-3">
                            <div class="form-group">
                                <label class="control-label">帮惠点击单价</label>
                                <input class="form-control input-sm" type="number" name="costPrice" [(ngModel)]="promotion.costPrice" required/>
                            </div>
                        </div>

                        <div class="col-md-3">
                            <div class="form-group">
                                <label class="control-label">点击单价</label>
                                <input class="form-control input-sm" type="number" name="agentPrice" [(ngModel)]="promotion.agentPrice" required/>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                                <label class="control-label">团队奖励</label>
                                <input class="form-control input-sm" type="number" name="teamBonus" [(ngModel)]="product.teamBonus" required/>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                                <label class="control-label">投放价</label>
                                <input class="form-control input-sm" type="number" name="exFactoryPrice" [(ngModel)]="promotion.exFactoryPrice" required/>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-4">
                            <div class="form-group">
                                <label for="putOnTimeLimit" class="control-label">投放时效</label>
                                <select name="putOnTimeLimit" class="form-control input-sm" id="putOnTimeLimit" [(ngModel)]="promotion.putOnTimeLimit">
                                  <option value="24">24小时</option>
                                  <option value="48">48小时</option>
                                </select>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="form-group">
                                <label for="showForUserType" class="control-label">广告可看人群</label>
                                <div class="form-control">
                                    <label for="showForUserType0" class="checkbox-inline">
                                  <input type="checkbox" [checked]="promotion.showForUserTypes.indexOf('FirstAgentUser')>=0" name="showForUserType" id="showForUserType0" value="FirstAgentUser" (change)="changeTargetUserType('FirstAgentUser')"/>
                                  B1
                                </label>
                                    <label for="showForUserType1" class="checkbox-inline">
                                  <input type="checkbox" [checked]="promotion.showForUserTypes.indexOf('SecondAgentUser')>=0" name="showForUserType" id="showForUserType1" value="SecondAgentUser" (change)="changeTargetUserType('SecondAgentUser')"/>
                                  B2
                                </label>
                                    <label for="showForUserType2" class="checkbox-inline">
                                  <input type="checkbox" [checked]="promotion.showForUserTypes.indexOf('GeneralUser')>=0" name="showForUserType" id="showForUserType2" value="GeneralUser" (change)="changeTargetUserType('GeneralUser')"/>
                                  C
                                </label>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="form-group"><label for="" class="control-label"></label></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label>描述</label>
                        <ueditor [(ngModel)]="promotion.graphicContent" [config]="editorConfig" name="graphicContent" [loadingTip]="'加载中……'" (onReady)="onEditorReady" (onDestroy)="onEditorDestroy" (onContentChange)="onEditorContentChange"></ueditor>
                    </div>
                </div>

                <div class="modal-footer">
                    <button [disabled]="saving" type="button" class="btn btn-default btn-sm" (click)="close()">取消</button>
                    <button type="submit" class="btn btn-primary blue btn-sm" [disabled]="!createPromotionForm.form.valid">
                      <i class="fa fa-save"></i>
                      <span>保存</span>
                    </button>
                </div>

            </form>

        </div>
    </div>
</div>